package cn.aws360.boot.auth.api.exception.handler;

import cn.aws360.boot.base.api.exception.handler.GlobalExceptionHandler;
import cn.aws360.boot.base.api.pojo.response.ResultModel;
import cn.dev33.satoken.exception.NotPermissionException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author junnan
 */
@Slf4j
@RestControllerAdvice
public class AuthExceptionHandler extends GlobalExceptionHandler {

    @ExceptionHandler(NotPermissionException.class)
    public ResultModel<String> handlerException(NotPermissionException e) {
        return ResultModel.fail("缺少权限：" + e.getPermission());
    }

}
